real.analysis = function() {
  mutate.lm = function(result) {
    fit = get(result, envir=1)
    mutate(tidy(fit), Result=result, N=nobs(fit), k=fit$rank, SSR=sum(fit$residuals^2))
  }
  
  tab2col1 = lm(Q1 ~ Citizen + Firm, data=dv_survey)
  tab2col1 = mutate.lm('tab2col1')
  tab2col2 = lm(Q1 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_survey)
  tab2col2 = mutate.lm('tab2col2')
  tab2col2inter = lm(Q1 ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=dv_survey)
  tab2col2inter = mutate.lm('tab2col2inter')
  
  tab2col3 = lm(Q1 ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=dv_survey)
  tab2col3 = mutate.lm('tab2col3')
  tab2col5 = lm(Q1 ~ Citizen + Firm, data=subset(dv_survey, CentNom<0.5))
  tab2col5 = mutate.lm('tab2col5')
  tab2col6 = lm(Q1 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=subset(dv_survey, CentNom<0.5))
  tab2col6 = mutate.lm('tab2col6')
  tab2col7 = lm(Q1 ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=subset(dv_survey, CentNom<0.5))
  tab2col7 = mutate.lm('tab2col7')
  
  tab2col1livestock = lm(Livestock ~ Citizen + Firm, data=dv_survey)
  tab2col1livestock = mutate.lm('tab2col1livestock')
  tab2col2livestock = lm(Livestock ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_survey)
  tab2col2livestock = mutate.lm('tab2col2livestock')
  tab2col2livestockinter = lm(Livestock ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=dv_survey)
  tab2col2livestockinter = mutate.lm('tab2col2livestockinter')
  
  tab2col3livestock = lm(Livestock ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=dv_survey)
  tab2col3livestock = mutate.lm('tab2col3livestock')
  tab2col6livestock = lm(Livestock ~ Citizen + Firm + FullTime + CentNom + Competitive, data=subset(dv_survey, CentNom<0.5))
  tab2col6livestock = mutate.lm('tab2col6livestock')
  
  tab2col1cultivation = lm(Cultivation ~ Citizen + Firm, data=dv_survey)
  tab2col1cultivation = mutate.lm('tab2col1cultivation')
  tab2col2cultivation = lm(Cultivation ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_survey)
  tab2col2cultivation = mutate.lm('tab2col2cultivation')
  tab2col2cultivationinter = lm(Cultivation ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=dv_survey)
  tab2col2cultivationinter = mutate.lm('tab2col2cultivationinter')
  tab2col3cultivation = lm(Cultivation ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=dv_survey)
  tab2col3cultivation = mutate.lm('tab2col3cultivation')
  tab2col6cultivation = lm(Cultivation ~ Citizen + Firm + FullTime + CentNom + Competitive, data=subset(dv_survey, CentNom<0.5))
  tab2col6cultivation = mutate.lm('tab2col6cultivation')
  
  placebo = rbind(cbind(data.frame(Prepared=dv_survey$Q1, Education=1L), subset(dv_survey, select=c(Citizen,Firm,FullTime,CentNom,Competitive))),
                  cbind(data.frame(Prepared=dv_survey$Livestock, Education=0L), subset(dv_survey, select=c(Citizen,Firm,FullTime,CentNom,Competitive))),
                  cbind(data.frame(Prepared=dv_survey$Cultivation, Education=0L), subset(dv_survey, select=c(Citizen,Firm,FullTime,CentNom,Competitive))))
  placebo.null = lm(Prepared ~ Citizen + Firm + Citizen + Firm + Education + FullTime + CentNom + Competitive, data=placebo)
  placebo.null = mutate(tidy(placebo.null), Result='placebo.null', N=nobs(placebo.null), k=placebo.null$rank, SSR=sum(placebo.null$residuals^2))
  placebo = lm(Prepared ~ Citizen + Firm + Citizen*Education + Firm*Education + FullTime + CentNom + Competitive, data=placebo)
  placebo = mutate(tidy(placebo), Result='placebo', N=nobs(placebo), k=placebo$rank, SSR=sum(placebo$residuals^2))
  
  dv_pooled = subset(dv_pooled, !is.na(Treatment))
  dv_floor = subset(dv_floor, !is.na(Treatment))
  dv_query = subset(dv_query, !is.na(Treatment))
  dv_caucus = subset(dv_caucus, !is.na(Treatment))
  
  tab3col1 = lm(Spoke ~ Citizen + Firm, data=dv_pooled)
  tab3col1 = mutate.lm('tab3col1')
  tab3col2 = lm(Spoke ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_pooled)
  tab3col2 = mutate.lm('tab3col2')
  tab3col3 = lm(Spoke ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=dv_pooled)
  tab3col3 = mutate.lm('tab3col3')
  tab3col4 = lm(Spoke ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=dv_floor)
  tab3col4 = mutate.lm('tab3col4')
  tab3col5 = lm(Spoke ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=dv_query)
  tab3col5 = mutate.lm('tab3col5')
  tab3col6 = lm(Spoke ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=dv_caucus)
  tab3col6 = mutate.lm('tab3col6')
  
  tab3col3x = lm(Spoke ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_pooled)
  tab3col3x = mutate.lm('tab3col3x')
  tab3col3xinter = lm(Spoke ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=dv_pooled)
  tab3col3xinter = mutate.lm('tab3col3xinter')
  tab3col4x = lm(Spoke ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_floor)
  tab3col4x = mutate.lm('tab3col4x')
  tab3col4xinter = lm(Spoke ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=dv_floor)
  tab3col4xinter = mutate.lm('tab3col4xinter')
  tab3col5x = lm(Spoke ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_query)
  tab3col5x = mutate.lm('tab3col5x')
  tab3col5xinter = lm(Spoke ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=dv_query)
  tab3col5xinter = mutate.lm('tab3col5xinter')
  tab3col6x = lm(Spoke ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_caucus)
  tab3col6x = mutate.lm('tab3col6x')
  tab3col6xinter = lm(Spoke ~ Citizen*Competitive + Firm*Competitive + FullTime + CentNom, data=dv_caucus)
  tab3col6xinter = mutate.lm('tab3col6xinter')
  
  tab3col7 = lm(Spoke ~ Citizen + Firm + FullTime + CentNom + Competitive, data=subset(dv_pooled, CentNom<0.5))
  tab3col7 = mutate.lm('tab3col7')
  tab3col8 = lm(Spoke ~ Citizen*Prop.Citizen + Firm*Prop.Firm + FullTime + CentNom + Competitive, data=subset(dv_pooled, CentNom<0.5))
  tab3col8 = mutate.lm('tab3col8')
  
  dv_pooled = ddply(dv_pooled, 'Province', function(x) {
    df = apply(x[,c('Citizen','Firm','FullTime','CentNom','Competitive')], 2, mean) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(c('Citizen','Firm','FullTime','CentNom','Competitive'))
    df = apply(x[,match('said_own_province', colnames(x)):match('Spoke', colnames(x))], 2, function(y) {
      as.integer(any(y>0))
    }) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(paste0('any_', colnames(x)[match('said_own_province', colnames(x)):match('Spoke', colnames(x))])) %>%
      cbind(df, .)
  })
  dv_caucus = ddply(dv_caucus, 'Province', function(x) {
    df = apply(x[,c('Citizen','Firm','FullTime','CentNom','Competitive')], 2, mean) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(c('Citizen','Firm','FullTime','CentNom','Competitive'))
    df = apply(x[,match('said_own_province', colnames(x)):match('Spoke', colnames(x))], 2, function(y) {
      as.integer(any(y>0))
    }) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(paste0('any_', colnames(x)[match('said_own_province', colnames(x)):match('Spoke', colnames(x))])) %>%
      cbind(df, .)
  })
  dv_query = ddply(dv_query, 'Province', function(x) {
    df = apply(x[,c('Citizen','Firm','FullTime','CentNom','Competitive')], 2, mean) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(c('Citizen','Firm','FullTime','CentNom','Competitive'))
    df = apply(x[,match('said_own_province', colnames(x)):match('Spoke', colnames(x))], 2, function(y) {
      as.integer(any(y>0))
    }) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(paste0('any_', colnames(x)[match('said_own_province', colnames(x)):match('Spoke', colnames(x))])) %>%
      cbind(df, .)
  })
  dv_floor = ddply(dv_floor, 'Province', function(x) {
    df = apply(x[,c('Citizen','Firm','FullTime','CentNom','Competitive')], 2, mean) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(c('Citizen','Firm','FullTime','CentNom','Competitive'))
    df = apply(x[,match('said_Article_02', colnames(x)):match('Spoke', colnames(x))], 2, function(y) {
      as.integer(any(y>0))
    }) %>%
      matrix(nrow=1) %>%
      as.data.frame %>%
      set_colnames(paste0('any_', colnames(x)[match('said_Article_02', colnames(x)):match('Spoke', colnames(x))])) %>%
      cbind(df, .)
  })
  dv_floor$any_said_Article_07 = 0L
  dv_not_query = apply(dv_floor[,paste0('any_said_', c('citizens','firms','objectives','vocational','teachers','fees','Article_02','Article_04','Article_07','Article_26','Article_27'))] + 
                         dv_caucus[,paste0('any_said_', c('citizens','firms','objectives','vocational','teachers','fees','Article_02','Article_04','Article_07','Article_26','Article_27'))], 2, pmin, 1) %>%
    as.data.frame %>%
    cbind(dv_pooled[,c('Province','FullTime','CentNom','Competitive','Citizen','Firm')], .)
  
  tab4col1 = lm(any_said_own_province ~ Citizen + Firm, data=dv_pooled)
  tab4col1 = mutate.lm('tab4col1')
  tab4col2 = lm(any_said_own_province ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_pooled)
  tab4col2 = mutate.lm('tab4col2')
  tab4col3 = lm(any_said_own_province ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_query)
  tab4col3 = mutate.lm('tab4col3')
  tab4col4 = lm(any_said_own_province ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_caucus)
  tab4col4 = mutate.lm('tab4col4')
  
  tab5col1 = lm(any_said_citizens ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_not_query)
  tab5col1 = mutate.lm('tab5col1')
  tab5col2 = lm(any_said_firms ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_not_query)
  tab5col2 = mutate.lm('tab5col2')
  tab5col3 = lm(any_said_objectives ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_not_query)
  tab5col3 = mutate.lm('tab5col3')
  tab5col4 = lm(any_said_vocational ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_not_query)
  tab5col4 = mutate.lm('tab5col4')
  tab5col5 = lm(any_said_teachers ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_not_query)
  tab5col5 = mutate.lm('tab5col5')
  tab5col6 = lm(any_said_fees ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_not_query)
  tab5col6 = mutate.lm('tab5col6')
  
  tab5col3alt = lm(any_said_Article_02 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_not_query)
  tab5col3alt = mutate.lm('tab5col3alt')
  tab5col4alt = lm(any_said_Article_04 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_not_query)
  tab5col4alt = mutate.lm('tab5col4alt')
  tab5col5alt = lm(any_said_Article_07 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_not_query)
  tab5col5alt = mutate.lm('tab5col5alt')
  tab5col6alt = lm(any_said_Article_26 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_not_query)
  tab5col6alt = mutate.lm('tab5col6alt')
  tab5col7alt = lm(any_said_Article_27 ~ Citizen + Firm + FullTime + CentNom + Competitive, data=dv_not_query)
  tab5col7alt = mutate.lm('tab5col7alt')
  
  fig4a = lm(Missing ~ Citizen, data=subset(dv_survey, Firm==0))
  fig4a = mutate.lm('fig4a')
  fig4b = lm(Missing ~ Firm, data=subset(dv_survey, Citizen==0))
  fig4b = mutate.lm('fig4b')
  
  rbind(fig4a, fig4b, 
        tab2col1, tab2col2, tab2col3, tab2col5, tab2col6, tab2col7, tab2col2inter,
        tab3col1, tab3col2, tab3col3, tab3col4, tab3col5, tab3col6, tab3col7, tab3col8,
        tab3col3x, tab3col4x, tab3col5x, tab3col6x,
        tab3col3xinter, tab3col4xinter, tab3col5xinter, tab3col6xinter,
        tab4col1, tab4col2, tab4col3, tab4col4,
        tab5col1, tab5col2, tab5col3, tab5col4, tab5col5, tab5col6,
        tab5col3alt, tab5col4alt, tab5col5alt, tab5col6alt, tab5col7alt,
        tab2col1livestock, tab2col2livestock, tab2col3livestock, tab2col6livestock,
        tab2col1cultivation, tab2col2cultivation, tab2col3cultivation, tab2col6cultivation,
        tab2col2livestockinter, tab2col2cultivationinter, placebo, placebo.null) %>%
    mutate(Iteration.Analysis=0L)
}
